home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / format / rfc2domsinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.9 KB  |  163 lines

  1. /* rfc2domsinfo.c - Converts a RFC string to a DomSupInfo struct */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/format/RCS/rfc2domsinfo.c,v 6.0 1991/12/18 20:22:06 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/format/RCS/rfc2domsinfo.c,v 6.0 1991/12/18 20:22:06 jpo Rel $
  9.  *
  10.  * $Log: rfc2domsinfo.c,v $
  11.  * Revision 6.0  1991/12/18  20:22:06  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include <isode/cmd_srch.h>
  20. #include "mta.h"
  21. #include "tb_p1.h"
  22.  
  23.  
  24. extern CMD_TABLE        p1tbl_domsinfo[],
  25.             p1tbl_action[];
  26.  
  27.  
  28.  
  29.  
  30. /* ---------------------  Begin  Routines  -------------------------------- */
  31.  
  32.  
  33.  
  34.  
  35. int rfc2domsinfo (dp, str)
  36. DomSupInfo      *dp;
  37. char            *str;
  38. {
  39.     char    *cp = str,
  40.         *bp = str,
  41.         *ptr;
  42.  
  43.     PP_DBG (("Lib/rfc2domsinfo (%s)", str));
  44.  
  45.     if ((cp = index (str, ' ')) == NULLCP)
  46.         return NOTOK;
  47.     else
  48.         *cp++ = '\0';
  49.  
  50.  
  51.     /* -- arrival -- */
  52.     if (lexequ (bp, rcmd_srch (DSI_TIME, p1tbl_domsinfo)) == 0) {
  53.         bp = cp;
  54.         if ((cp = rindex (cp, ':')) == NULLCP)
  55.             return NOTOK;
  56.         if ((ptr = index (cp, '+')) == NULLCP)
  57.             ptr = index (cp, '-');
  58.         if (ptr)
  59.             cp = ptr;
  60.         if ((cp = index (cp, ' ')) != NULLCP)
  61.             *cp++ = '\0';
  62.         if (rfc2UTC (bp, &dp->dsi_time) == NOTOK)
  63.             return NOTOK;
  64.     }
  65.     else
  66.         return NOTOK;
  67.  
  68.  
  69.     /* -- optional stuff now follows  -- */
  70.     if ((bp = cp) == NULLCP)
  71.         return OK;
  72.     if ((cp = index (bp, ' ')) == NULLCP)
  73.         return NOTOK;
  74.     else
  75.         *cp++ = '\0';
  76.  
  77.  
  78.  
  79.     /* -- deferred -- */
  80.     if (lexequ (bp, rcmd_srch (DSI_DEFERRED, p1tbl_domsinfo)) == 0) {
  81.         bp = cp;
  82.         if ((cp = rindex (cp, ':')) == NULLCP)
  83.             return NOTOK;
  84.         if ((ptr = index (cp, '+')) == NULLCP)
  85.             ptr = index (cp, '-');
  86.         if (ptr)
  87.             cp = ptr;
  88.         if ((cp = index (bp, ' ')) != NULLCP)
  89.             *cp++ = '\0';
  90.         if (rfc2UTC (bp, &dp->dsi_deferred) == NOTOK)
  91.             return NOTOK;
  92.         if ((bp = cp) == NULLCP)
  93.             return OK;
  94.         if ((cp = index (bp, ' ')) == NULLCP)
  95.             return NOTOK;
  96.         else
  97.             *cp++ = '\0';
  98.     }
  99.  
  100.  
  101.  
  102.     /* -- action -- */
  103.     if (lexequ (bp, rcmd_srch (DSI_ACTION, p1tbl_domsinfo)) == 0) {
  104.         bp = cp;
  105.  
  106.         if ((cp = index (bp, ' ')) != NULLCP)
  107.             *cp++ = '\0';
  108.  
  109.         switch (cmd_srch (bp, p1tbl_action)) {
  110.         case ACTION_RELAYED:
  111.             dp->dsi_action = ACTION_RELAYED;
  112.             break;
  113.         default:
  114.             dp->dsi_action = ACTION_ROUTED;
  115.             break;
  116.         }
  117.  
  118.         if ((bp = cp) == NULLCP)
  119.             return OK;
  120.         if ((cp = index (bp, ' ')) == NULLCP)
  121.             return NOTOK;
  122.         else
  123.             *cp++ = '\0';
  124.     }
  125.  
  126.  
  127.  
  128.     /* -- converted -- */
  129.     if (lexequ (bp, rcmd_srch (DSI_CONVERTED, p1tbl_domsinfo)) == 0) {
  130.         if ((cp = index (cp, '(')) == NULLCP)
  131.             return NOTOK;
  132.         else
  133.             bp = ++cp;
  134.  
  135.         if ((cp = index (bp, ')')) == NULLCP)
  136.             return NOTOK;
  137.         else
  138.             *cp++ = '\0';
  139.  
  140.         if (rfc2encinfo (&dp->dsi_converted, bp) == NOTOK)
  141.             return NOTOK;
  142.  
  143.         bp = cp;
  144.         if ((cp = index (bp, ' ')) == NULLCP)
  145.             return OK;
  146.         else
  147.             *cp++ = '\0';
  148.     }
  149.  
  150.  
  151.  
  152.     /* -- attempted -- */
  153.     if (lexequ (bp, rcmd_srch (DSI_ATTEMPTED, p1tbl_domsinfo)) == 0) {
  154.         bp = cp;
  155.         if (rfc2globalid (&dp->dsi_attempted_md, bp) == NOTOK)
  156.             return NOTOK;
  157.     }
  158.  
  159.  
  160.     return OK;
  161.  
  162. }
  163.